Super Robot Wars is an engaging series of tactical turn-based video games that captivate players with their unique blend of popular anime storylines, such as Gundam, Mazinger Z, Getter Robo, Neon Genesis Evangelion, and more. The above screenshot serves only as an illustration. In project assignment 1, we have customized rules to simulate key gameplay mechanics.
For a complete example, please refer to the
side-by-side comparision example
below
Upon completing this project assignment, you will achieve the following learning outcomes:
A skeleton code:
pa1_skeleton.zip
is provided.
Sample input and output files are included in the zip file.
cin or cout statements
The initial game information: Robot B HP=99 Robot C HP=500 Robot Z HP=1000 Z . . . . . . . . . . . . . . . . . . . . . . . . . . B . . . . C . . . . . . . . . . . . . . . . . The move action is not implemented yet The move action is not implemented yet The move action is not implemented yet The move action is not implemented yet The move action is not implemented yet The hit action is not implemented yet The hit action is not implemented yet The shoot action is not implemented yet The shoot action is not implemented yet === Game Ended ===
3 B 99 C 500 Z 1000
| Name | Characters | Description |
|---|---|---|
| Empty Cell | . |
The . (dot) character represents an empty cell. Empty cells cannot be moved. |
| Robot | A-Z |
These characters represent robots. Robots can be moved. |
5 10 Z......... .......... .......B.. ..C....... ..........
In this example, you can see:
Z moves east 2 Z moves north 1 Z moves south 4 Z moves south 3 Z moves south 2 Z hits south Z hits east Z shoots north Z shoots east !

[Robot Letter] moves [direction word] [number of steps]
| Sentence | Description |
|---|---|
| Z moves east 2 | Move the robot Z to the east direction by 2 steps. |
| B moves north 1 | Move the robot B to the north direction by 1 step. |
| C moves south 4 | Move the robot C to the south direction by 4 steps. |


| Movement | Before the operation | After the operation | Reason |
|---|---|---|---|
| Z moves east 2 |
|
|
Success: Robot Z moves along the direction east by 2 step(s) |
| Z moves north 1 |
|
|
Fail: If robot Z moves along the direction north by 1 step(s), it will move outside a boundary, so the position remains unchanged |
| Z moves south 4 |
|
|
Fail: If robot Z moves along the direction south by 4 step(s), it will hit another robot along the path, so the position remains unchanged |
| Z moves south 3 |
|
|
Fail: If robot Z moves along the direction south by 3 step(s), it will hit another robot along the path, so the position remains unchanged |
| Z moves south 2 |
|
|
Success: Robot Z moves along the direction south by 2 step(s) |
// Weapon: for the hit action
const int WEAPON_HIT_DAMAGE = 200;
WEAPON_HIT_DAMAGE
[Robot Letter] hits [direction word]

| Movement | Current map | Result |
|---|---|---|
| Z hits south |
|
|
| Z hits east |
|
|
// Weapon: for the shoot action
const int WEAPON_SHOOT_DAMAGE = 100;
const int WEAPON_SHOOT_RANGE = 5;
WEAPON_SHOOT_RANGE steps
WEAPON_SHOOT_DAMAGE
[Robot Letter] shoots [direction word]

| Movement | Current map | Result |
|---|---|---|
| Z shoots north |
|
|
| Z shoots east |
|
|
| A sample input | A sample output
To enhance readability, when lines become excessively long, they are wrapped into multiple lines |
|---|---|
|
|
! to indicate the end of the robot operations
Task1: Implementing the updateMapForMoveAction function
// TODO:
// function updateMapForMoveAction: updates the map and returns the status value after the robot movement
// @param map: a 2D character array storing the game map
// @param mapRows: the number of rows of the game map
// @param mapCols: the number of columns of the game map
// @param robotLetter: the robot to be moved
// @param directionLetter: the movement direction
// @param moveSteps: the number of steps to be moved along the direction
//
// @return: the status value, please check the constant values near the top of the starter code.
// The main function may also help you understand the meanings of the possible return values
//
int updateMapForMoveAction(char map[MAX_ROWS][MAX_COLS], const int mapRows, const int mapCols,
const char robotLetter, const char directionLetter, const int moveSteps)
{
// remove this line to start your work
return STATUS_ACTION_MOVE_NOT_IMPLMENTED;
}
Task2: Implementing the updateHealthPointsForHitAction function
// TODO:
// function updateHealthPointsForHitAction: updates the map, healthPoints, and returns the values to the main function after the hit action
//
// @param healthPoints: a 1D array storing the healthPoints of robots
// @param map: a 2D character array storing the game map
// @param mapRows: the number of rows of the game map
// @param mapCols: the number of columns of the game map
// @param robotLetter: the robot to be moved
// @param directionLetter: the movement direction
// @param targetRobotLetter: the target robot.
// @param targetOriginalHealthPoint: the original health point of the target robot.
// @param targetUpdatedHealthPoint: the updated health point of the target robot.
//
// Note: The pass-by-reference variables will be returned and used in the main function.
//
// @return: the status value, please check the constant values near the top of the starter code.
// The main function may also help you understand the meanings of the possible return values
int updateHealthPointsForHitAction(int healthPoints[MAX_NUM_ROBOTS],
char map[MAX_ROWS][MAX_COLS],
const int mapRows, const int mapCols,
const char robotLetter,
const char directionLetter,
char &targetRobotLetter,
int &targetOriginalHealthPoint,
int &targetUpdatedHealthPoint)
{
// remove this line to start your work
return STATUS_ACTION_WEAPON_NOT_IMPLEMENTED;
}
Task3: Implementing the updateHealthPointsForShootAction function
// TODO:
// function updateHealthPointsForShootAction: updates the map, healthPoints, and returns the values to the main function after the shoot action
//
// @param healthPoints: a 1D array storing the healthPoints of robots
// @param map: a 2D character array storing the game map
// @param mapRows: the number of rows of the game map
// @param mapCols: the number of columns of the game map
// @param robotLetter: the robot to be moved
// @param directionLetter: the movement direction
// @param targetRobotLetter: the target robot.
// @param targetOriginalHealthPoint: the original health point of the target robot.
// @param targetUpdatedHealthPoint: the updated health point of the target robot.
//
// Note: The pass-by-reference variables will be returned and used in the main function.
//
// @return: the status value, please check the constant values near the top of the starter code.
// The main function may also help you understand the meanings of the possible return values
int updateHealthPointsForShootAction(int healthPoints[MAX_NUM_ROBOTS],
char map[MAX_ROWS][MAX_COLS],
const int mapRows, const int mapCols,
const char robotLetter,
const char directionLetter,
char &targetRobotLetter,
int &targetOriginalHealthPoint,
int &targetUpdatedHealthPoint)
{
// remove this line to start your work
return STATUS_ACTION_WEAPON_NOT_IMPLEMENTED;
}
Many students forget to initialize the variables before using them. Sometimes, it will cause serious problems. In most of the operating systems (e.g., Linux), variables won't be initialized (i.e., there are garbage values stored if the variables are not initialized and being used.)
ZINC is running in Linux, so variables won't be initialized automatically.
The following method can ask the compiler to check uninitialized variables. For example,
the
following code is stored in a file named uninitialized_variables.cpp, you
can add a
flag -Wuninitialized to check:
g++ uninitialized_variables.cpp -Wuninitialized
The above technique may be useful for your labs and projects. Here is a demo in vscode:

Similar to labs, you should follow similar steps to run the test cases. You won't see your ZINC grading report before the deadline.
Limitations of the ZINC system:
Please compare your outputs with the desired outputs:
g++ -std=c++11 pa1.cpp -o pa1
./pa1 < testcase/input1.txt > myOutput1.txt
Get-Content testcase/input1.txt | ./pa1 > myOutput1.txt
Please replace the filenames accordingly if you would like to check other output files.
Students may use different operating systems (e.g., Windows/Mac/Linux), so the executable file is prepared in Virtual Barn.
If you want to run the sample executable, you should follow How to run pa1.exe? tutorial
The following test cases are released:
| Sample Input | Sample Output | Description |
|---|---|---|
| input1.txt | output1.txt |
|
| input2.txt | output2.txt |
|
| input3.txt | output3.txt |
|
| input4.txt | output4.txt |
|
| input5.txt | output5.txt |
|
| input6.txt | output6.txt |
|
| input7.txt | output7.txt |
|
| input8.txt | output8.txt |
|
In addition to the given test cases, we have hidden test cases. They are summarized in the following table:
(*): In this project assignment, we may not able to completely isolate one feature from another feature. So, we only list out the main area in the following table.
| Main Area (*) | Number of Given Test Cases |
Number of Hidden Test Cases |
Total Marks in Each Area |
|---|---|---|---|
| Robot Movement | 2 | 14 | 16 (1 mark for each case) |
| Hit Operations | 2 | 8 | 10 (1 mark for each case) |
| Shoot Operations | 3 | 11 | 28 (2 marks for each case) |
| Mixed Operations | 1 | 2 | 15 (5 marks for each case) |
| Total | 8 | 35 |
MaxTotal = 69
will be normalized to 100 (i.e. YourTotal / MaxTotal * 100) ZINC will normalize your total score to 100.0 when the grades are released. |
We highly value academic integrity. Please read the Honor Code section on our course webpage to make sure you understand what is considered as plagiarism and what the penalties are. The followings are some of the highlights:
This programming assignment is challenging, so you are highly recommended to start early. If you need clarification on the requirements, please feel free to post on Piazza. However, to avoid cluttering the forum with repeated/trivial questions, please carefully read the given code, the description, the sample output, and the latest FAQ (refresh this page regularly) in this page before you post your questions. In addition, please be reminded that we won't help debug for any student's assignment for the sake of fairness.
You are required to submit your solution to our auto-grading
system: ZINC.
Please read the
ZINC student submission guidelines
if you still don't know how to submit in ZINC.
The filename is pa1.cpp, and submit it to ZINC. 50% penalty will be given if your filename is wrong. You don't need to zip the file if you only submit one file to ZINC.
Filename checking is enabled in ZINC. If your filename is wrong, you should see something like this:

Other names do not work (e.g., PA1.cpp, Pa1.cpp, pa1.cpp.cpp, pa 1.cpp (a space is added between pa and 1) etc. )
Notes:
Make sure your program can be compiled and be able to execute.
If we cannot even compile your work, it won't be graded. Therefore, for parts that you cannot finish, just put in dummy/empty implementation so that your whole program can be compiled for ZINC to grade the other parts that you have done.
There will be a penalty of -1 point (out of a maximum 100 points) for every
minute you
are late.
In other words, if you are late for more than 100 minutes, you will get 0
marks.
This section will be updated after the release
As the assignment is a major course assessment, to be fair, we should not
finish the
tasks for you.
We might provide you some hints, but we won't debug for you.